import enquireJs from 'enquire.js'

export function isDef (v){
  return v !== undefined && v !== null
}

/**
 * Remove an item from an array.
 */
export function remove (arr, item) {
  if (arr.length) {
    const index = arr.indexOf(item)
    if (index > -1) {
      return arr.splice(index, 1)
    }
  }
}

export function isRegExp (v) {
  return _toString.call(v) === '[object RegExp]'
}

export function enquireScreen(call) {
  const handler = {
    match: function () {
      call && call(true)
    },
    unmatch: function () {
      call && call(false)
    }
  }
  enquireJs.register('only screen and (max-width: 767.99px)', handler)
}

export function toTitle(str) {
  if(str.length > 0)
  {
    return str.charAt(0).toUpperCase() + str.slice(1)
  }else
  {
    return str
  }
}

export function isEmpty(str)
{
  if (str === null || str === undefined || str === '')
    return true
  else
    return false
}

const _toString = Object.prototype.toString
